home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
Mops 2.7
/
Mops source
/
System source
/
ANSI
< prev
next >
Wrap
Text File
|
1993-06-15
|
3KB
|
133 lines
\ ANSI shell - Sept 92.
\ Loading this file should give you an ANSI Forth system.
\ We implement the CORE word set (of course), the ERROR and ERROR EXT words,
\ and most of the CORE EXT words.
\ The only CORE EXT words NOT implemented are:
\ C" CONVERT EXPECT MARKER ROLL SPAN
\ Of these, CONVERT, EXPECT and SPAN are obsolete, and ROLL is inefficient
\ and rather useless.
need longMath
\ First, Mops defines a number of words as compile-only, which have to
\ be EXECUTEable in ANSI. We'll make them state-smart in the next
\ Mops version.
: 1+ 1 + ;
: 2+ 2 + ;
: 3+ 3 + ;
: 4+ 4 + ;
: 1- 1 - ;
: 2- 2 - ;
: 3- 3 - ;
: 4- 4 - ;
: 2* 1 << ;
: 2/ 1 a>> ;
: 4* 2 << ;
: 4/ 2 >> ;
:code 2@
move.l (a6),a0
move.l 4(a0),(a6)
push.l (a0)
;code
:code 2!
pop.l a0
pop.l (a0)+
pop.l (a0)
;code
:code 2OVER
push.l 12(a6)
push.l 12(a6)
;code
:code 2SWAP
movem.l (a6)+,d0-d3
push.l d1
push.l d0
push.l d3
push.l d2
;code
\ Our : is immediate, and gives an error if not in execution state.
\ ANSI : isn't immediate, and is legal within definitions.
: : 0 -> state
postpone : ;
: CREATE <builds ;
: BASE ['] base ; \ BASE is a variable, not a value
: STATE ['] state ; \ Likewise STATE
\ ENVIRONMENT is the only CORE word that takes much implementing!
string+ ENV$
: (ENV) \ ( -- false | x true )
" /CHAR" search: env$ if 1 true exit then
" /COUNTED-STRING" search: env$ if 255 true exit then
" /HOLD" search: env$ if 30 true exit then
" /PAD" search: env$ if 200 true exit then
" /TIB" search: env$ if 400 true exit then
" ADDRESS-UNIT-BITS" search: env$ if 8 true exit then
" ALIGN" search: env$ if 2 true exit then
" CORE" search: env$ if true true exit then
" CORE-EXT" search: env$ if false true exit then
" FULL" search: env$ if true true exit then
" ERROR-HANDLING" search: env$ if true true exit then
" ERROR-HANDLING-EXT" search: env$ if true true exit then
" MAX-CHAR" search: env$ if 255 true exit then
" MAX-D" search: env$ if -1 big# true exit then
" MAX-N" search: env$ if big# true exit then
" MAX-U" search: env$ if -1 true exit then
" MAX-UD" search: env$ if -1 -1 true exit then
" RETURN-STACK-CELLS" search: env$ if RstkSpace 4/ true exit then
" STACK-CELLS" search: env$ if StkSpace 4/ true exit then
( none matched ) false ;
: ENVIRONMENT \ ( addr len -- false | x true )
put: env$ false -> case?
(env)
release: env$ ;
\ CORE EXT words:
:code 2>R
move.l (a6)+,-(a7)
move.l (a6)+,-(a7)
;code
:code 2R>
move.l (a7)+,-(a6)
move.l (a7)+,-(a6)
;code
:code 2R@
push.l 4(a7)
push.l (a7)
;code
: TO postpone -> ; immediate
: [COMPILE] postpone postpone ; immediate
: WITHIN over - >r - r> u< ;
false -> slctrs? \ Disable selectors -- in ANSI, XXX: is a
\ normal Forth word